<?php

//session_start();

$conn = new Connection();
$categories = $conn->fetchCategory($_SESSION['LOGIN_INFO']['id']);
$categories = urldecode($categories);
$categories = json_decode($categories, true);


//echo "<pre>";print_r($sub_categories);echo "</pre>";exit;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-TW" lang="zh-TW">

<head>
  <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" /> 
  <link rel="stylesheet" type="text/css" href="styles/css/html.css" media="screen, projection, tv " />
  <link rel="stylesheet" type="text/css" href="styles/css/layout.css" media="screen, projection, tv" />
  <link rel="stylesheet" type="text/css" href="styles/css/print.css" media="print" />
  <link rel="stylesheet" type="text/css" href="styles/css/jquery.fancybox-1.3.1.css"  />
  <script src="styles/js/jquery.js" type="text/javascript"></script>
  <script src="styles/js/ajax.js" type="text/javascript"></script>
  <script src="styles/js/ulikewall.js" type="text/javascript"></script>
  <script src="styles/js/jquery.fancybox-1.3.1.pack.js" type="text/javascript"></script>
  <script src="https://www.google.com/jsapi?key=<?php echo GOOGLE_API_KEY;?>" type="text/javascript"></script>
  
</head>

<body id="editListBody" >
<p>
<!-- CONTENT: Holds all site content except for the footer.  This is what causes the footer to stick to the bottom -->
<div id="content" class="width100">
  
    	<table id="category_list">
    		<tbody>
      <?php
      if (! empty($categories[0])) {
      	$the_uncategory_index = count($categories)-1;
          foreach ($categories as $category_key=>$categories_val) {
          	if($category_key != $the_uncategory_index){
              echo '<tr>';
              echo '<td class="title" id="category_title_'.$category_key.'">'.$categories_val.'</td>';
              echo '<td class="rename" id="rename_button_'.$category_key.'"><input type="button" value="重新命名" onclick="showCategoryRenameTitle(\''.$category_key.'\')"/></td>';
              echo '<td id="deleteCategory_'.$category_key.'"><img src="styles/images/icons/unsubscribe.png" style="cursor:pointer;" onclick="deleteCategory(\''.$category_key.'\')"/></td>';
              echo '</tr>';
			  echo '<tr class="feed-row"><td colspan="3">&nbsp;</td></tr>';
			}
          }
      }

	  ?>
	  	</tbody>
	  </table>
</div>
<div>
    <span><input type="text" id="new_category" /></span>
	<span><input type="button" value="新增分類" id="addCategoryButton" onclick="addCategory();"/></span>
</div>
</p>
</body>

</html>